package com.sgb.member.ui.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.sgb.member.BR;
import com.sgb.member.R;
import com.sgb.member.databinding.ItemMemberAuditBinding;
import com.sgb.member.databinding.ItemMemberAuditPersonBinding;
import com.sgb.member.entity.MemberBean;
import com.sgb.member.entity.MemberPersonBean;
import com.sgb.member.weight.SimpleResult;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import com.swgk.core.util.ClickUtils;

import java.util.List;

/**
 * Created by：冯齐 on 2021/1/4 10:22
 * Description：
 */
public class MemberAuditPersonAdapter extends BaseRecycleAdapter<MemberPersonBean> {
    private final int type;
    private SimpleResult<MemberPersonBean> simpleResult;

    public void setSimpleResult(SimpleResult<MemberPersonBean> simpleResult) {
        this.simpleResult = simpleResult;
    }
    public MemberAuditPersonAdapter(Context context, List<MemberPersonBean> datas, int type) {
        super(context, R.layout.item_member_audit_person, datas);
        this.type = type;
    }


    @Override
    public void convert(ItemViewHolder holder, final MemberPersonBean entity) {
        ((ItemMemberAuditPersonBinding) holder.getmBinding()).setType(type);
        holder.setBinding(BR.viewModel, entity);
        ImageView auditStatus = holder.itemView.findViewById(R.id.audit_status);//审核状态
        switch (entity.status) {
            case 1:
                auditStatus.setImageResource(R.mipmap.member_icon_dsh);
                break;
            case 2:
                auditStatus.setImageResource(R.mipmap.member_icon_passed);
                break;
            case 3:
                auditStatus.setImageResource(R.mipmap.member_icon_yjj);
                break;
        }
        TextView tv_audit = holder.itemView.findViewById(R.id.tv_audit);
        tv_audit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(!ClickUtils.isDoubleClick()){
                    if(simpleResult != null){
                        simpleResult.onResult(entity);
                    }
                }
            }
        });
    }
}
